<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	</head>
	<body>
		<script>
			// 父类
			function ParentAttr(name, age) {
				this.name = "name"
				this.age = "age"
			}

			// 父类2
			function ParentFn(skill) {
				this.skill = function() {
					return skill
				}
			}

			// 父类3
			function ParentProto(attr) {
				this.fn = function() {
					return attr
				}
			}

			// 子类
			function SonFn(name, age, work, skill) {
				this.name = name
				this.age = age
				this.work = function() {
					return this.name + " " + this.age + " " + work
				}
				ParentAttr.call(this, name, age)
				// ParentFn.call(this, skill)
				SonFn.prototype.fn = function() {
					return "fn"
				}
			}
			SonFn.prototype = new ParentProto("ab")

			// 子类实例
			var instance = new SonFn("小明", 18, ["教师", "程序员"], "WEB APP H5")

			console.log(instance.work(), "instance")
			console.log(instance.fn(), "ParentProto")

			/*
			 * divider =================================================================
			 */

			function Pfn(...args) {
				const [name = "ab", type = 1] = args
				this.name = name
				this.type = type
				this.fn = function() {
					console.log("fn")
				}
				Pfn.prototype.Pfn = function() {
					console.log("Pfn")
				}
			}

			function Cfn() {
				Cfn.prototype.Pfn = function() {
					console.log("Cfn")
				}
				Pfn.call(this)
			}

			Cfn.prototype.Pfn = new Pfn().Pfn
			Cfn.prototype.skill = new Pfn().name + ", " + new Pfn().type
			// console.log(Pfn.prototype.Pfn, 1)

			const NCfn = new Cfn()
			// console.log(NCfn, "NCfn")
			NCfn.Pfn()

			/*
			 * divider =================================================================
			 */

			function A(...args) {}
			A.prototype.name = "A"
			A.prototype.type = "AT"
			A.prototype.work = "AW"

			function B(...args) {}
			B.prototype.name = "B"
			B.prototype.type = "BT"
			B.prototype.work = "BW"
			B.prototype = new A()

			function C(...args) {}
			C.prototype.name = "C"
			C.prototype.type = "CT"
			C.prototype.work = "CW"
			// C.prototype = new A()
			C.prototype = new B()

			const NC = new C()
			console.log(NC, NC.work, "NC")
		</script>
	</body>
</html>